<!DOCTYPE html>
<html lang="en">
<head>
	<{include file="header.html"}>
	<title>科目管理-<{$user_data['school_name']}>-德安信会计在线教育平台</title>
</head>
<body>
<div class="wrap">
	<!--star left-->
	<div class="column">
		<{include file="left_menu.html"}>
	</div>
	<div id="ContMianBox">
		<!--star子栏目-->
		<div class="sub-colum">
            <div class="tit"><{$left_menu_min.menu}></div>
            <ul>
                <{foreach from=$left_menu_min.list item=item}>
                <li <{if $item['url'] == $left_menu_min.curr}>class="curr"<{/if}>><a href="<{$item['url']}>"><{$item['name']}></a></li>
                <{/foreach}>
            </ul>
        </div>
		<!--end子栏目-->
		<!--end left-->
		<div class="container narrow">
		    <!--star conter-->
		    <div class="cetContent">
				<div class="tit p-lr20">
				    <span class="curr">科目管理</span>
				    <span><a href="/subject/chapter_list">章节管理</a></span>
				</div>
				<!--star内容区域-->
				<div class="mainScroll">
				    <div class="mainContainer line-all">
				        <!--star tabMainCont-->
				        <div class="tabMainCont">
				            <!--star会员管理-->
							<fieldset class="layui-elem-field">
								<legend>按条件搜索</legend>
								<div class="layui-field-box">
									<form class="layui-form layui-form-pane1" method="post" action="<{$current_url}>">
										<div class="layui-form-item">
											<div class="layui-inline">
												<input type="text" name="title" placeholder="科目名称" value="<{if !empty($conditions['title']) }><{$conditions['title']}><{/if}>" class="layui-input">
											</div>

											<div class="layui-inline">
												<select name="tk_category_id">
													<option value="0">按分类筛选</option>
													<{foreach from=$category_list item=citem}>
													<option value="<{$citem.id}>" <{if isset($conditions.tk_category_id) AND $conditions.tk_category_id == $citem.id}>selected<{/if}>><{$citem.name}></option>
													<{/foreach}>
												</select>
											</div>

											<div class="layui-inline">
												<select name="pack_status">
													<option>上架状态</option>
													<option value="1" <{if isset($conditions.pack_status) AND $conditions.pack_status == 1}>selected<{/if}>>上架</option>
													<option value="2" <{if isset($conditions.pack_status) AND $conditions.pack_status == 2}>selected<{/if}>>未上架</option>
												</select>
											</div>
											
											<div class="layui-inline">
												<button type="submit" class="layui-btn">搜索</button>
												<a class="layui-btn" href="/subject/add"><i class="layui-icon"></i> 添加科目</a>
											</div>
										</div>
									</form>
								</div>
							</fieldset>
		                	<form class="layui-form layui-form-pane1" method="post" delete_action="/subject/delete">
								<table class="layui-table" lay-even lay-skin="row">
								  	<thead>
									  	<tr>
										  	<tr>
										  	<th>分类名称</th>
												<th>科目名称</th>
												<th>章节管理</th>
												<th>状态</th>
												<th>操作</th>
											</tr>
									  	</tr>
								  	</thead>
								  	<tbody>
								  	<{foreach from=$subject_list item=item}>
										<tr>
										<td class="center"><{$item['name']}></td>
											<td class="center"><a style="font-weight: bold;" href="/subject/chapter_list/<{$item.id}>"><{$item['title']}></a></td>
											<td>
												<a class="layui-btn layui-btn-primary layui-btn-small" href="/subject/chapter_list/<{$item['id']}>">章节管理</a>
											</td>
											<td class="center">
												<{if $item.status == 0}>
												<a class="layui-btn layui-btn-primary layui-btn-small up" subject_id="<{$item['id']}>" pack_id="<{$item.pack_id}>" href="javascript:;">上架</a>
												<{else}>
												<a class="layui-btn layui-btn-primary layui-btn-small up" subject_id="<{$item['id']}>" pack_id="<{$item.pack_id}>" href="javascript:;">修改上架信息</a>
												<a class="layui-btn layui-btn-primary layui-btn-small down" subject_id="<{$item['id']}>" pack_id="<{$item.pack_id}>" href="javascript:;">下架</a>
												<{/if}>
											</td>
											<td class="center">
												<a class="layui-btn layui-btn-primary layui-btn-small" href="/subject/edit/<{$item['id']}>" target="_blank"><i class="layui-icon"></i></a>
												<a class="layui-btn layui-btn-primary layui-btn-small delete_data" href="/subject/delete/<{$item['id']}>"><i class="layui-icon"></i></a>
												
												
											</td>
										</tr>
									<{/foreach}>
								  	<{if $subject_list|count eq 0}>
								  		<tr>
									  		<td class="center" style=" height:120px; text-align:center;line-height:120px;" colspan="5">
												赞无数据！
											</td>
									  	</tr>
								  	<{/if}>
							  		</tbody>
							  	</table>
						  	</form>
			                <div class="pages p-tb20" style="text-align:right;">
			                    <{$pagination}>
			                </div>
			            </div>
			            <!--star会员管理-->
			        </div>
				        <!--end tabMainCont-->
		        </div>
		    </div>
		</div>
	</div>
</div>
<{include file="footer.html"}>
<script type="text/javascript">
	$(".up").click(function(){
		layer.open({
			type: 2,
			title: '科目上架',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '340px'],
			maxmin: true,
			content: '/subject/shelves/'+$(this).attr("subject_id")+'/'+$(this).attr("pack_id") //iframe的url
		});
	})

	$(".down").click(function(){
		$.ajax({
			type: "POST",
			url: "/subject/shelves_down/" + $(this).attr("pack_id"),
			dataType:"json",
			async:false,
			data:{'subject_id':$(this).attr("subject_id"),'pack_id':$(this).attr("pack_id")},
			contentType:'application/x-www-form-urlencoded',
			success: function(result){
				if(result.code == 1){
					var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	        		parent.layer.close(index);
	        		parent.layer.msg('已下架', {
				        icon: 1,
				        shade:0.5,
				        time: 2000 //2秒关闭（如果不配置，默认是3秒）
				    });
				}
			}
		});
	})
</script>
</body>
</html>